package com.suke.czx.modules.examstack.controller;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import com.suke.czx.modules.examstack.entity.ExamPaperEntity;
import com.suke.czx.modules.examstack.service.ExamPaperService;
import com.suke.czx.common.utils.PageUtils;
import com.suke.czx.common.utils.Query;
import com.suke.czx.common.utils.R;




/**
 * 
 * 
 * @author Larry
 * @email lawhw@163.com
 * @date 2018-11-01 23:17:48
 */
@RestController
@RequestMapping("/exam/exampaper")
public class ExamPaperController {
    @Autowired
    private ExamPaperService examPaperService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("exam:exampaper:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<ExamPaperEntity> examPaperList = examPaperService.queryList(query);
        int total = examPaperService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(examPaperList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("exam:exampaper:info")
    public R info(@PathVariable("id") Integer id){
			ExamPaperEntity examPaper = examPaperService.queryObject(id);

        return R.ok().put("examPaper", examPaper);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("exam:exampaper:save")
    public R save(@RequestBody ExamPaperEntity examPaper){
			examPaperService.save(examPaper);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("exam:exampaper:update")
    public R update(@RequestBody ExamPaperEntity examPaper){
			examPaperService.update(examPaper);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("exam:exampaper:delete")
    public R delete(@RequestBody Integer[] ids){
			examPaperService.deleteBatch(ids);

        return R.ok();
    }
	
}
